<template>
  <view class="list-item-bottom">
    <!-- 底部按钮组 -->
    <!-- 暂时不做物流模块 -->
    <view class="order-operate-section">
      <view
        class="cancle-btn button-xl"
        @click.stop="handleCancle(orderitem, operateBtnWord.greyStr)"
        v-if="operateBtnWord.greyStr"
        >{{ operateBtnWord.greyStr }}</view
      >
      <view
        class="confirm-btn button-xl"
        v-if="operateBtnWord.redStr"
        @click.stop="handleConfirm(orderitem, operateBtnWord.redStr)"
        >{{ operateBtnWord.redStr }}</view
      >
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    orderitem: {
      type: Object,
      default: () => {
        return {};
      },
    },
    status: {
      type: Number,
      default: 0,
    },
  },
  computed: {
    operateBtnWord() {
      let redStr = "",
        greyStr = "";
      // 0所有可售后订单  1处理中订单 2已完成订单
      if (this.orderitem.is_user_cancel == 1) {
        greyStr = this.$t('order.del');
      } else {
        if (this.status == 0) {
          if (
            this.orderitem.is_agree == 0 &&
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_user_send == 0
          ) {
            redStr = this.$t('title.orderRefund');
          }
        }
        if (this.status == 1) {
          if (
            this.orderitem.is_agree == 0 &&
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_user_send == 0
          ) {
            redStr = this.$t('order.detail');
            greyStr = this.$t('order.cancleApp');
          }
          if (
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_agree == 1 &&
            this.orderitem.is_user_send == 0
          ) {
            redStr = this.$t('order.fillExp');
            greyStr = this.$t('order.cancleApp');
          }
          if (
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_agree == 1 &&
            this.orderitem.is_user_send == 1
          ) {
            redStr = this.$t('order.detail');
          }
        }
        if (this.status == 2) {
          if (this.orderitem.refund_status == 1) {
            redStr = this.$t('order.detail');
            greyStr = this.$t('order.del');
          }
          if (this.orderitem.refund_status == 3) {
            redStr = this.$t('diy.contact');
          }
        }
      }
      // 售后状态为已完成时
      // if (this.orderitem.is_agree > 0 && this.orderitem.refund_status > 0) {
      //   redStr = this.$t('order.detail');
      //   greyStr = this.$t('order.delete');
      // }

      // 售后状态为处理中时
      // if ((this.orderitem.is_agree > 0 || this.orderitem.refund_status > 0) && this.orderitem.is_user_send == 0) {
      //   redStr = this.$t('order.fillExp');
      //   greyStr = "";
      // }

      // 售后状态为申请中时
      // if (this.orderitem.is_agree == 0 && this.orderitem.refund_status == 0) {
      //   redStr = this.$t('order.detail');
      //   greyStr = "";
      // }

      return { redStr, greyStr };
    },
  },
  filters: {
    priceBeforeZero(val) {
      if (val.indexOf(".") < 0) return `${val}.`;
      return val.substr(0, val.indexOf("."));
    },
    priceAfterZero(val) {
      if (val.indexOf(".") < 0) return "00";
      return val.substr(val.indexOf("."), val.lenhth);
    },
  },
  methods: {
    handleCancle(item, type) {
      this.$emit("handleCancle", { item, type });
    },
    handleConfirm(item, type) {
      this.$emit("handleConfirm", { item, type });
    },
  },
};
</script>

<style lang="scss" scoped>
.list-item-bottom {
  margin-top: 30rpx;
  display: flex;
  justify-content: flex-end;
  align-items: center;

  .order-price {
    font-size: 30rpx;
    font-family: PingFang SC;
    font-weight: 400;
    color: #262626;
    line-height: 44rpx;
    display: flex;
    align-items: baseline;

    text:nth-child(2) {
      font-size: 24rpx;
    }
    text:nth-child(3) {
      font-size: 30rpx;
    }
    text:nth-child(4) {
      font-size: 24rpx;
    }
  }

  .order-operate-section {
    display: flex;
    justify-content: flex-end;
    align-items: center;

    .button-xl {
      font-size: 26rpx;
      font-family: PingFang SC;
      font-weight: 400;
      width: 152rpx;
      height: 60rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 30rpx;
    }

    .cancle-btn {
      color: #262626;
      border: 2rpx solid #8c8c8c;
    }

    .confirm-btn {
      color: #f7271f;
      border: 2rpx solid #f7271f;
      margin-left: 24rpx;
    }
  }

  .list-item-bottom-list {
    display: flex;
    justify-content: flex-end;

    view {
      width: 152rpx;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      margin-left: 22rpx;
      font-size: 26rpx;
      border-radius: 30rpx;
    }

    navigator {
      width: 152rpx;
      height: 60rpx;
      line-height: 60rpx;
      text-align: center;
      margin-left: 22rpx;
      font-size: 26rpx;
      border-radius: 30rpx;
    }

    .item-bottom-list-one {
      border: 1rpx solid #8e8e8e;
      color: #262626;
    }

    .item-bottom-list-two {
      color: #f22a10;
      border: 1rpx solid #f22a10;
    }
  }
}
</style>
